﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace CustomControls.Atoms
{
    public partial class CounterControl : UserControl
    {
        public CounterControl()
        {
            InitializeComponent();
        }

        //private int maximum_;

        //public int MaximumValue
        //{
        //    get { return maximum_; }
        //    set
        //    {
        //        maximum_ = value;
        //        CountBox.Text = CurrentValue.ToString() + "/" + MaximumValue.ToString();
        //    }
        //}

        private int value_;

        public int CurrentValue
        {
            get { return value_; }
            set 
            {
                LessButton.Enabled = value > 0;
                value_ = value;
                CountBox.Text = CurrentValue.ToString(); //+"/" + MaximumValue.ToString();
            }
        }

        public bool CanAdd
        {
            get { return addEnabled_; }
            set
            {
                addEnabled_ = value;
                PlusButton.Enabled = value;
            }
        }

        public event EventHandler onPlus;
        public event EventHandler onMinus;

        private void PlusButton_Click(object sender, EventArgs e)
        {
            onPlus.Invoke(this, null);
        }

        private void LessButton_Click(object sender, EventArgs e)
        {
            onMinus.Invoke(this, null);
        }

        private bool addEnabled_;
    }

}
